microbenchmarks: add buffer rotation option#677
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in --rotating-buffers mode to the microbenchmarks to cycle input tensors through a buffer ring, reducing artificial cache-residency effects and aligning measurements with common GEMM benchmarking methodology.
Changes:
- Introduces buffer-rotation utilities (
rotating,make_input) and a new CLI flag--rotating-buffers [N]in the shared microbenchmark runner. - Updates several benchmarks (GEMM, FP8 GEMM, normalization, grouped GEMM, casting) to use rotation-aware input construction.
- Documents the new option and usage examples in the microbenchmarks README.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| benchmarks/microbenchmarks/utils.py | Adds rotation machinery + CLI flag plumbing and helper APIs used by benchmarks. |
| benchmarks/microbenchmarks/README.md | Documents --rotating-buffers behavior and provides example invocations. |
| benchmarks/microbenchmarks/benchmark_normalization.py | Switches normalization benchmarks to rotation-aware input generation. |
| benchmarks/microbenchmarks/benchmark_grouped_gemm.py | Updates grouped GEMM benchmark to optionally follow rotated activation buffers. |
| benchmarks/microbenchmarks/benchmark_gemm.py | Switches GEMM benchmark to rotation-aware input generation. |
| benchmarks/microbenchmarks/benchmark_gemm_fp8.py | Switches FP8 GEMM benchmark to rotation-aware input generation. |
| benchmarks/microbenchmarks/benchmark_casting.py | Uses rotation-aware inputs for quantize path and rotates FP8 tensors for dequantize path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ed4f3e7 to
3209e8e
Compare
| python benchmark_casting.py --rotating-buffers 16 # or fix the ring size (16 buffers) | ||
| ``` | ||
|
|
||
| Passing `--rotating-buffers N` fixes the number of buffers; omitting `N` |
There was a problem hiding this comment.
Generally we would specify the # of bytes that the rotating buffer uses rather than the # of buffers -- I think that can be generally set to a safely large value, such as 4/8
| ), | ||
| ) | ||
| parser.add_argument( | ||
| "--rotating-buffers", nargs="?", type=int, const=0, default=None, metavar="N", |
There was a problem hiding this comment.
I would argue for this to be on by default, as a standard benchmarking practice
Description
Add a new option, --rotating-buffers, to rotate input buffers (off by default).
Follows the discussions in:
Type of change
Changes
Checklist: